//
//  ProductSubViewController.m
//  UEAssistant
//
//  Created by mac on 2017/7/24.
//  Copyright © 2017年 youyixinxi. All rights reserved.
//

#import "ProductSubViewController.h"
#import "DetailsViewController.h"
#import "FilesViewController.h"
#import "ToolspViewController.h"
#import "TickersViewController.h"

@interface ProductSubViewController ()<MMTabBarViewDelegate,MMTabBarViewDataSource>

@property (nonatomic, strong) NSMutableArray                                *dataArr;
@property (nonatomic, strong) UIView                                        *cusNavigationView;


@end

@implementation ProductSubViewController

- (void)viewWillAppear:(BOOL)animated{

    [self.navigationController.navigationBar setHidden:YES];
}

- (void)viewWillDisappear:(BOOL)animated{

    [self.navigationController.navigationBar setHidden:NO];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initDataSource];
    [self initUserface];
}


- (void)initDataSource{

}

- (void)initUserface{
    
    self.view.backgroundColor = [UIColor whiteColor];
    [LSProgressHUD showLoadingToView:self.view];
    self.delegate = self;
    self.dataSource = self;
    [self creatCustomNavigationView];

    self.gradientType = MMTabBarViewGradientTypeMasking;
    self.layoutType   = MMTabBarViewTextLayoutByEqualDivision;
    [self reload];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.6 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [LSProgressHUD hiddenLoading:self.view];
    });
}

//自定义视图替换原生导航栏
- (void)creatCustomNavigationView{
    
    [self.view addSubview:self.cusNavigationView];
}


#pragma mark -- MMTabBarViewDataSource

- (NSArray *)infomationsForViewController:(MMTabBarViewController *)tabBarViewController{
    return [self.dataArr copy];
}

- (NSUInteger )numberOfItemsInViewController:(MMTabBarViewController *)tabBarViewController {
    return self.dataArr.count;
}

- (MMTabBarModel *)infomationInViewController:(MMTabBarViewController *)tabBarViewController infoForItemAtIndex:(NSUInteger)index {
    return self.dataArr[index];
}

#pragma mark -- get

- (NSMutableArray *)dataArr {
    if (!_dataArr) {
        _dataArr = [NSMutableArray array];
        NSArray *data = @[@[@"DetailsViewController",@"详情    "],
                          @[@"FilesViewController",@"文件    "],
                          @[@"ToolspViewController",@"工具    "],
                          @[@"TickersViewController",@"订单    "]];
        for (int i = 0; i < data.count; i++) {
            [_dataArr addObject:[MMTabBarModel modelWithControllerClassName:[data[i] firstObject]  controllerTitle:[data[i] lastObject]]];
        }
    }
    return _dataArr;
}

- (UIView *)cusNavigationView{
    
    if (_cusNavigationView == nil) {
        _cusNavigationView = [[UIView alloc]initWithFrame:CGRectMake(0, 110-1, Screen_Width, 1)];
        _cusNavigationView.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1];
    }
    return _cusNavigationView;
}


@end
